<template>
	<view class="page">
		<!-- #ifdef H5-ONLY -->
		<theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
		</theme-navbar>
		<!-- #endif -->

		<view class="content u-page">

			<me-table :i="0" :index="0" :top="0" :load-data="loadData" :height="getListViewHeight()" :init-load="false"
				ref="mescrollItem0">
				<view slot-scope="d" class="list-item-root">
					<view class="list-lay">
						<storeBoxListItem :isAddGoods="detailInfo.isAddGoods" :itemInfo="d.data"></storeBoxListItem>
					</view>
				</view>
			</me-table>

			<view class="submit-btns btn-other-cls" v-if="detailInfo.isAddGoods">
				<u-button class="u-btn" type="primary" @click="addStoreBox">
					添加物品
				</u-button>
			</view>
		</view>


	</view>
</template>

<script>
	import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
	import meTable from "@/components/me-table.vue";
	import storeBoxListItem from "./../components/storeBoxListItem.vue";
	import storeService from '@/service/store/store.service.js';
	
	
	export default {
		components: {
			meTable,
			storeBoxListItem,
		},
		data() {
			return {
				detailInfo: {}
			}
		},
		onLoad() {
			this.detailInfo = this.getRouteParam();
			console.log(this.detailInfo)
		},
		
		methods: {
			getListViewHeight() {
				let p = this.$u.sys().windowHeight - 44 - 57 - 40 - uni.upx2px(10) - this.$u.sys().statusBarHeight + "px";
				// #ifdef H5-DINGDING || H5-WECHAT
				p = this.$u.sys().windowHeight - uni.upx2px(10) - 57 - 40 - this.$u.sys().statusBarHeight + "px";
				// #endif
				return p;
			},
			loadData(page) {
				let paras = Object.assign(this.detailInfo,{status:1,docName:this.detailInfo.fullDocName});
				let params = {
				  page: page.num,
				  limit: page.size,
				  paras: paras,
					 // paras: {storeBill:"R20240428000073"},//测试调试接口
				};
				return new Promise((resolve, reject) => {
					storeService.storeBoxCodeList(params).then(res=>{
						if (res.code == 0 && res.success) {
						  resolve({count: res.count,data: res.data,});
						} else {
						  resolve({count: 0,data: [],});
						}
					}).catch((err)=>{
						this.$u.toast("请求失败:" + e);
						resolve({count: 0,data: [],});
					})
				})
			},
			addStoreBox(){
				this.setRouteParam({
					...this.detailInfo
				});
				this.$u.route("/pages/store/box/addStoreGoods");
			},
			goBack(){
				this.backPrev({
					paramKey: 'refreshBox',
					param: true,
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "@/style/common/rightMenu.scss";

	page {
		background-color: #f3f4f5;

	}

	.page {
		padding: 0 !important;
	}

	.content {
		background-color: #f3f4f5;
	}

	.pop-content-lay {
		padding: 20rpx;
		display: flex;
		height: 100%;
		flex-direction: column;
		justify-content: center;
	}

	.grid-text {
		font-size: 28rpx;
		margin-top: 4rpx;
		color: $u-type-info;
	}

	.list-lay {
		margin: 10px;
	}

	.list-item-root {
		margin: 10px;
		border-radius: 15px;
		overflow: hidden;
		border-bottom: 1px solid $u-border-color;
		background-color: #fff;
	}
</style>